// 2025/11/5
// x的平方根

class Solution {
public:
    int mySqrt(int x) {
        long long l = 0, r = x;
        int ans = 0;
        while(l <= r)
        {
            long long mid = (l + r) >> 1;
            if(mid * mid == x) 
                return mid;
            else if(mid * mid > x)
                r = mid - 1;
            else
            {
                l = mid + 1;
                ans = mid;
            }
        }
        return ans;
    }
};